Dera Adugna

Dera Adugna

Senior Backend Developer

Posted on August 17, 2023

Get system ready

Update the package list on the system and get all the latest security patches.

sudo apt update

Setup ZSH

This section installs and configures the ZSH shell and its plugins. The commands are as follows:

  • sudo apt install zsh: installs the ZSH shell.
  • sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)": installs Oh My Zsh, a community-driven framework for managing Zsh configuration.
  • git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions: installs the Zsh Autosuggestions plugin, which suggests commands based on your command history as you type.
  • git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting: installs the Zsh Syntax Highlighting plugin, which highlights commands as you type them.

The following line adds the plugins to the ZSH configuration file:

plugins=( 
    git
    zsh-syntax-highlighting
    zsh-autosuggestions
)

Git

This section installs and configures Git. The commands are as follows:

  • sudo apt install git: installs Git.
  • git config --global user.name "Your Name": sets the Git username.
  • git config --global user.email "youremail@domain.com": sets the Git email.

Nodejs

This section installs Node.js and npm. The commands are as follows:

  • sudo apt install nodejs: installs Node.js.
  • sudo apt install npm: installs npm, the package manager for Node.js.

Docker

This section installs and configures Docker. The commands are as follows:

  • sudo apt install apt-transport-https ca-certificates curl software-properties-common: installs the necessary packages for Docker.
  • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -: adds the Docker GPG key.
  • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable": adds the Docker repository.
  • apt-cache policy docker-ce: checks the Docker version.
  • sudo apt install docker-ce: installs Docker.
  • sudo systemctl status docker: checks the Docker status.
  • sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose: installs Docker Compose, a tool for defining and running multi-container Docker applications.
  • sudo chmod +x /usr/local/bin/docker-compose: makes Docker Compose executable.
  • docker-compose --version: checks the Docker Compose version.

SSH

This section generates an SSH key and adds it to GitHub/Bitbucket. The commands are as follows:

  • cd ~: changes to the home directory.
  • eval $(ssh-agent): starts the SSH agent.
  • ssh-keygen -t ed25519 -b 4096 -C "{username@emaildomain.com}" -f {ssh-key-name}: generates an SSH key.
  • ssh-add ~/{ssh-key-name}: adds the SSH key to the SSH agent.
  • cat .ssh/{ssh-key-name}.pub: displays the public key.
  • Add the public key to your GitHub/Bitbucket account.

SSH Clone

This section clones a repository using SSH. The command is as follows:

  • git clone git@bitbucket.org:***: clones the repository using SSH.

Nginx

This section installs and configures Nginx. The commands are as follows:

  • sudo apt-get update: updates the package list.
  • sudo apt-get install certbot python3-certbot-nginx: installs Certbot and the Certbot Nginx plugin.
  • sudo nano /etc/nginx/sites-available/default: opens the Nginx configuration file.
  • The following code block is added to the configuration file:
server {
    listen 80;
    server_name hello.app;
    location / {
        proxy_pass http://localhost:4000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

This code block sets up a reverse proxy to redirect traffic from port 80 to port 4000.

  • sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/: creates a symbolic link to enable the configuration.
  • sudo nginx -t: tests the Nginx configuration.
  • sudo systemctl reload nginx: reloads the Nginx configuration.
  • sudo certbot certonly --nginx -d default: generates an SSL certificate for the domain.
  • sudo openssl x509 -noout -text -in /etc/letsencrypt/live/default.app/fullchain.pem: displays the SSL certificate information.
  • The following code block is added to the configuration file:
server {
    listen 443 ssl;
    server_name hello.app;
    
    ssl_certificate /etc/letsencrypt/live/default.app/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/default.app/privkey.pem;
    location / {
        proxy_pass http://localhost:4000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

This code block sets up SSL for the domain.

  • sudo nginx -t: tests the Nginx configuration.
  • sudo systemctl reload nginx: reloads the Nginx configuration.

NCDU Disk Management

This section installs NCDU, a disk usage analyzer. The command is as follows:

  • sudo apt install ncdu: installs NCDU.

Coming Soon

  • Jenkins CI/CD